#! /usr/bin/env sh

# Generate documentation for the vidprofile suite from txt2tags
# input files. See http://txt2tags.sourceforge.net/ for
# documentation on the input format.

ME="[mkdocs ]:"

SOURCE="./src"
HTML_DEST="./html"
MAN_DEST="."

# Generate (X)HTML
TOHTML_OPTS="-t xhtml"
TOHTML_FILES=`find $SOURCE -name "*.t2t" -and -not -name "incl-*.t2t" | sort`

rm -f $HTML_DEST/*.html
rm -f $MAN_DEST/*.man

echo "$ME Making html files..."

for FILE in $TOHTML_FILES
do
    INFILE="--infile=$FILE"
    OUTFILE="--outfile=$HTML_DEST/`basename $FILE .t2t`.html"
    txt2tags $TOHTML_OPTS $INFILE $OUTFILE >> /dev/null
done

# Generate manpages
TOMAN_OPTS="-t man"
TOMAN_FILES="src/profile.t2t \
             src/vidpsnr.t2t \
             src/psnrcore.t2t"

echo "$ME Making man pages..."

for FILE in $TOMAN_FILES
do
    INFILE="--infile=$FILE"
    OUTFILE="--outfile=$MAN_DEST/`basename $FILE .t2t`.man"
    txt2tags $TOMAN_OPTS $INFILE $OUTFILE >> /dev/null
done

echo "$ME Docs made!"
echo

exit 0
